# !/usr/bin/env python
# encoding: utf-8


"""
  @author: gaogao
  @file: calculate_utils.py
  @time: 2022/3/4 10:28
  @desc:
"""


# 计算LOSS_GC
def cal_loss_gc(p_in, p_out, loss_sys, loss_wg):
    if all([p_in, p_out, loss_sys, loss_wg]):
        loss_gc = (float(p_in) - float(p_out) - float(loss_sys) - float(loss_wg)) / 2
        return loss_gc


# 计算P_IN_PD
def cal_p_in_pd(p_in, loss_sys, loss_gc, loss_wg):
    if all([p_in, loss_sys, loss_gc, loss_wg]):
        p_in_pd = float(p_in) - float(loss_sys) - float(loss_gc) - float(loss_wg)
        return p_in_pd


# 计算响应度
def cal_r(i_light, p_in_pd):
    if all([i_light, p_in_pd]):
        r = float(i_light) / float(p_in_pd)
        return r


# 计算光学损耗
def cal_il_mod(p_in_mod, p_out_mod, loss_gc):
    if all([p_in_mod, p_out_mod, loss_gc]):
        il_mod = float(p_in_mod) - float(p_out_mod) - 2 * float(loss_gc)
        return il_mod


# 计算终端电阻阻值
def cal_r_terml(v_bias, i_mod):
    if all([v_bias, i_mod]):
        r_terml = float(v_bias) / float(i_mod)
        return r_terml

# 计算MZI1的值

